package com.ag.wzp.dao;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.ag.bean.TbDisposalAdvice;
import com.ag.dao.TbDisposalAdviceDAO;
import common.Logger;
/**
 * 
 * @author 温镇澎
 *
 */
@Repository("wzpTbDisposalAdviceDAO")
public class WzpTbDisposalAdviceDAO extends TbDisposalAdviceDAO {
	private static final Logger logger = Logger.getLogger(WzpTbDisposalAdviceDAO.class);
	
	private SessionFactory sessionFacotry;   
    @Resource  
    public void setSessionFacotry(SessionFactory sessionFacotry) {   
        this.sessionFacotry = sessionFacotry;   
    }   
    @PostConstruct  
    public void injectSessionFactory() {   
        super.setSessionFactory(sessionFacotry);
    }
    
	public List<TbDisposalAdvice> findAllDAByEId(String eId) {
		logger.debug("findAllDAByEId");
		try {
			String hql = "from TbDisposalAdvice t  left  join fetch t.tbUserByAdviceUId  left  join fetch t.tbUserBySubmitUId  left join fetch t.tbUserByApplyUId where t.tbEvent.EId = "+eId+" order by t.daSubmitTime desc";
			//String hql = "from TbDisposalAdvice da join fetch da.tbSubmit s join fetch s.tbDept " +
			//		"join fetch s.tbEvent e join fetch da.tbUser where e.EId = "+eId;
			return getHibernateTemplate().find(hql);
		} catch (RuntimeException re) {
			logger.error("findAllDAByEId failed", re);
			throw re;
		}
	} 
    
    
}
